home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / comm / comm1 / klrkcmsr.lha / Comment.C < prev    next >
C/C++ Source or Header  |  1995-12-17  |  5KB  |  153 lines

  1. #define KILLER_COMMENT_MAIN
  2.  
  3. #include "COMMENT.H"
  4.  
  5. void main (int argc, char *argv[])
  6. {
  7.    char temp[300], temp2[300];
  8.    int   i;
  9.     BOOL    success = FALSE , show_comment = FALSE;
  10.  
  11.     Register(atoi(argv[1]));
  12.  
  13.     // What did the user type to start this door? This NEEDS to be done
  14.     // know or otherwise /X won't know the main line anymore. S.T.U.P.I.D.!
  15.     temp[ 2 ] = 0x00;
  16.     getuserstring( temp , BB_MAINLINE );
  17.  
  18.     // Initialise what we need (memory, read icons, etc. etc.)
  19.    Initialise();
  20.  
  21.     // Time to load the preferences
  22.     LoadPrefs();
  23.  
  24.     // Does this user want to know the statistics?
  25.     if ( temp[ 2 ] == '?' )
  26.     {
  27.         getuserstring( temp2 , DT_SECSTATUS );
  28.         i = atoi( temp2 );
  29.         if ( i >= gn_ptr->gn_view_access )
  30.             Commentistics();
  31.     }
  32.  
  33.     // How many words did he enter?
  34.     i = WordCount( temp );
  35.  
  36.     // If there was more than one argument on the main line, an argument has
  37.     // been entered after it. If so, check if it can be related to one of
  38.     // the users in the comment list.
  39.     if ( i > 1 )
  40.     {
  41.         // First of all, copy ONLY the arguments to temp2, we do this by
  42.         // searching for a space after the first word, we copy the remainder
  43.         // of that string to temp2.
  44.         for ( i = 0 ; i < strlen( temp ) ; i ++ )
  45.         {
  46.             if ( temp[ i ] == ' ' )
  47.             {
  48.                 i += 2;
  49.                 break;
  50.             }
  51.         }
  52.         strmid ( temp , temp2 , i , strlen( temp ) );
  53.  
  54.         // Make sure to remove any asterisk that may have been put after
  55.         // the argument(s)
  56.         if ( temp2[ strlen( temp2 ) - 1 ] == '*' )
  57.             temp2[ strlen( temp2 ) - 1 ] = 0x00;
  58.  
  59.         // First of all we check if the given argument(s) is a number. If it
  60.         // is, the ToNumber() function will select the appropriate user and
  61.         // return a TRUE value.
  62.         if ( ToNumber ( temp2 ) == TRUE )
  63.             success = TRUE;
  64.         else
  65.             // It's not a number. Well, is the given argument longer than 2
  66.             // characters? If not, it's to ambigious to start comparing.
  67.             if ( strlen ( temp2 ) > 2 )
  68.             {
  69.                 // The length is okay. Time to check if the argument given is
  70.                 // the FULL name of a user from the list. We do this to disable
  71.                 // any errors that might occur because user 2 has a part of user
  72.                 // 1 in it's name.
  73.                 if ( CompareNames( temp2 , STRICT_COMPARE ) == TRUE )
  74.                     success = TRUE;
  75.                 else
  76.                     // It's not a full name, now we go check if the arguments
  77.                     // fits a part of any user name. It takes the first name
  78.                     // that fits the description.
  79.                     if ( CompareNames( temp2 , FLEX_COMPARE ) == TRUE )
  80.                         success = TRUE;
  81.                     else
  82.                         // And if it's not even that, we go check if it's a piece
  83.                         // of any user-info. This also takes the first info that
  84.                         // fits the description.
  85.                         if ( CompareInfo ( temp2 ) == TRUE )
  86.                             success = TRUE;
  87.             }
  88.     }
  89.  
  90.     // Did we find a user or not? If so, put this brief message on screen.
  91.     if ( success )
  92.     {
  93.         sprintf( temp , "\n\r               KiLLER COMMENT v1.4 (c) 1995 by KiLLraVeN/MYSTiC\n\r\n\r               Writing to%s\n\r" , rc_node->rc_knownas );
  94.         sm( temp , 0 );
  95.     }
  96.  
  97.     // We either were not successful or there was just one argument given on
  98.     // the main line. That means we will let the user select one from the
  99.     // menu. This is done with the SelectReceiver() function.
  100.     if ( ! success || i <= 1 )
  101.         show_comment = success =  SelectReceiver();
  102.  
  103.     // Was there a user selected or not?
  104.     if ( success )
  105.     {
  106.         // Save the new stats of the choosen user
  107.         SaveNewStats();
  108.         // Do we need to show a comment line? If there was no filename given
  109.         // in the prefs OR the user selected a user with a specific argument
  110.         // we will NOT show a comment.
  111.         if ( rc_node->rc_comments[ 0 ] != 0x00 && show_comment )
  112.             ShowComment();
  113.         enddoor ( LEAVE_COMMENT );
  114.     }
  115.     else
  116.         enddoor ( EXIT_SILENTLY );
  117. }
  118.  
  119. void enddoor ( int RETURNCODE )
  120. {
  121.     char    Temp[100];
  122.  
  123.     // First of all, return the memory to the system
  124.     FreeNodes ( (struct List * ) &KC_Users0List );
  125.     if ( gn_ptr )
  126.         FreeVec ( gn_ptr );
  127.  
  128.     // Close any open icon and the icon.library
  129.     CloseIcon();
  130.     CloseLibrary(IconBase);
  131.  
  132.     // Determine way of exit - silent or with error/message ?
  133.     switch ( RETURNCODE )
  134.     {
  135.         case EXIT_SILENTLY:    sm( "\n\r" , 0);
  136.                                     break;
  137.  
  138.         case MEMORY_ERROR :    sm( "\n\rCOULDN'T ALLOCATE MEMORY!! DEFAULTING TO SYSOP!\n\r" , 0 );
  139.                                     break;
  140.  
  141.         case LEAVE_COMMENT:    sprintf( Temp , "e %s" , rc_node->rc_realname );
  142.                                     putuserstring( Temp , RETURNPRVCMD );
  143.                                     break;
  144.  
  145.         case EXIT_REGULAR_C:    putuserstring ("C" , RETURNCOMMAND );
  146.                              break;
  147.     }
  148.  
  149.     // Close the door-port to Ami-X and exit
  150.     ShutDown();
  151.     end();
  152. }
  153.